<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="柜组编号" prop="cabinetGroupNo">
        <el-input v-model="queryParams.cabinetGroupNo" placeholder="请输入柜组编号" clearable @clear="getDataList"/>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="getDataList">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>
    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="addOrUpdateHandle('add')" v-hasPermi="['deliver:deliverMember:add']">新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="success" plain icon="el-icon-edit" size="mini" :disabled="single" @click="addOrUpdateHandle" v-hasPermi="['deliver:deliverMember:edit']">修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="danger" plain icon="el-icon-delete" size="mini" :disabled="multiple" @click="deleteHandle" v-hasPermi="['deliver:deliverMember:remove']">删除</el-button>
      </el-col>
      <!-- <el-col :span="1.5">
        <el-button type="warning" plain icon="el-icon-download" size="mini" @click="exportHandle" v-hasPermi="['deliver:deliverMember:export']">导出</el-button>
      </el-col> -->
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getDataList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="dataList" @selection-change="dataListSelectionChangeHandle">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="ID" width="55" align="center" prop="id" />
      <el-table-column label="柜组编号" align="center" prop="cabinetGroupNo" />
      <el-table-column label="创建时间" align="center" prop="createtime" />
      <el-table-column label="更新时间" align="center" prop="updatetime" />
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button size="mini" type="text" icon="el-icon-s-grid" @click="cabinetHandle(scope.row)">查看智能柜</el-button>
          <el-button size="mini" type="text" icon="el-icon-edit" @click="addOrUpdateHandle(scope.row)" v-hasPermi="['deliver:deliverMember:edit']">修改</el-button>

          <el-button size="mini" type="text" icon="el-icon-delete" @click="deleteHandle(scope.row.id)" v-hasPermi="['deliver:deliverMember:remove']">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
    <pagination v-show="total>0" :total="total" :current-page.sync="pageNum" :page.sync="pageNum" :limit.sync="pageSize" @pagination="query" />
    <!-- 弹窗, 新增 / 修改 -->
    <add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"></add-or-update>
    <!-- 查看智能柜弹窗 -->
    <cabinetList v-if="cabinetListVisible" ref="cabinetList"></cabinetList> 
  </div>
</template>

<script>
import mixinViewModule from '@/mixins/view-module'
import AddOrUpdate from './index-add-or-update'  //新增修改的状态弹窗
import CabinetList from '../cabinetListDialog.vue'  //查看智能柜弹窗
export default {
  name: "CabinetGroup",
  mixins: [mixinViewModule],
  data() {
    return {
      mixinViewModuleOptions: {
        getDataListURL: '/cabinetGroup/list',
        getDataListIsPage: true,
        deleteURL: '/cabinetGroup/remove',
        deleteIsBatch: true
      },
      // 查询参数
      queryParams: {
        cabinetGroupNo: ''
      },
      cabinetListVisible:false, //智能柜弹窗是否显示
    };
  },
  components: {
    AddOrUpdate, //新增修改的状态弹窗
    CabinetList, //查看智能柜弹窗
  },
  created() {

  },
  methods: {
    // 点击查看智能柜
    cabinetHandle(row){
      this.cabinetListVisible = true
      this.$nextTick(() => {
        this.$refs.cabinetList.cabinetGroupNo = row.cabinetGroupNo
        this.$refs.cabinetList.init()
      })
    }
  }
};
</script>
